<?php
/**
 * +--------------------------------------------------------+
 * @Created by PhpStorm.
 * @Category AuthAdmin.php
 * @Depiction:
 * Author: hwy
 * Date: 2020/5/28  16:11
 * +--------------------------------------------------------+
 */

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;

class AuthAdmin
{
    public function handle($request, Closure $next){

        //如果没有登录;则重定向到登录页面

        if (!Auth::guard('admin')->check()) {
            return redirect()->route('login');
        }

        $route =  $request->decodedPath();
        $user = Auth::guard('admin')->user();
        // todo 权限先屏蔽
       // if($route != 'admin/test/index'){
       //     if (!$user->hasPermissionTo($route, 'admin')) {
       //         return redirect()->route('login');
       //         return response()->json([
       //             'code'    => 1001,
       //             'message' => "No authority",
       //         ], 401);
       //     }
       // }



        return $next($request);
    }
}
